<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unit tests for the TinyMCE core API</title>
<link rel="stylesheet" href="css/unit.css" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce_dev.js"></script>
<script type="text/javascript" src="js/testrunner.js"></script>
</head>
<body>
	<h1>Unit tests for DOM Range IE implementation</h1>
	<h2 id="banner"></h2>
	<h2 id="userAgent"></h2>
	<ol id="tests"></ol>
	<div id="main"></div>
	<div id="sample">
		<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p>
		<p id="second">bar</p>
		<p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p>
		<table id="table" width="300">
			<tr>
				<td>1</td>
				<td id="two">abc</td>
			</tr>
			<tr>
				<td>3</td>
				<td>4</td>
			</tr>
		</table>
		<p id="last">textabc<span>span</span></p>
	</div>

<script type="text/javascript">
$(window).load(function() {
	function createRng() {
		return document.createRange2 ? document.createRange() : new tinymce.dom.Range(tinymce.DOM);
	};

	function getHTML(co) {
		var div = document.createElement('div'), h;

		if (!co)
			return 'null';

		div.appendChild(co.cloneNode(true));
		h = div.innerHTML.toLowerCase();

		h = h.replace(/[\r\n\t]/g, ''); // Remove line feeds and tabs
		h = h.replace(/ (\w+)=([^\"][^\s>]*)/gi, ' $1="$2"'); // Restore attribs on IE

		return h;
	};

	function setup() {
		if (this.orgHTML)
			document.getElementById('sample').innerHTML = this.orgHTML;

		// Remove whitespace nodes to normalize IE and other browsers
		function clean(n) {
			var i;

			if (n.nodeType == 3 && /^[\s]+$/.test(n.nodeValue))
				return n.parentNode.removeChild(n);

			for (i = n.childNodes.length - 1; i >= 0; i--)
				clean(n.childNodes[i]);
		};

		clean(document.getElementById('sample'));

		this.orgHTML = document.getElementById('sample').innerHTML;
	};

	test("Initial state", function() {
		var r = createRng();

		setup();
		expect(5);

		equals(r.startContainer, document)
		equals(r.startOffset, 0)
		equals(r.endContainer, document)
		equals(r.endOffset, 0)
		equals(r.commonAncestorContainer, document)
	});

	test("setStartSetEnd", function() {
		var r = createRng();

		setup();
		expect(12);

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('strong').firstChild, 3);

		equals(r.startContainer.nodeValue, 'first')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeValue, 'strong')
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 3)
		equals(r.commonAncestorContainer.nodeName, 'P')

		r.setStart(document.getElementById('first'), 0);
		r.setEnd(document.getElementById('strong'), 0);

		equals(r.startContainer.nodeName, 'P')
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeName, 'STRONG')
		equals(r.endOffset, 0)
		equals(r.commonAncestorContainer.nodeName, 'P')
	});

	test("setStartBeforeSetEndAfter", function() {
		var r = createRng();

		setup();
		expect(5);

		r.setStartBefore(document.getElementById('first'));
		r.setEndAfter(document.getElementById('strong'));

		equals(r.startContainer.nodeName, 'DIV')
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeName, 'P')
		equals(r.endOffset, 5)
		equals(r.commonAncestorContainer.nodeName, 'DIV')
	});

	test("test_setStartAfterSetEndBefore", function() {
		var r = createRng();

		setup();
		expect(5);

		r.setStartAfter(document.getElementById('strong'));
		r.setEndBefore(document.getElementById('em'));

		equals(r.startContainer.nodeName, 'P')
		equals(r.startOffset, 5)
		equals(r.endContainer.nodeName, 'P')
		equals(r.endOffset, 6)
		equals(r.commonAncestorContainer.nodeName, 'P')
	});

	test("test_collapse", function() {
		var r = createRng();

		setup();
		expect(10);

		r.setStart(document.getElementById('strong').firstChild, 0);
		r.setEnd(document.getElementById('strong').firstChild, 6);

		r.collapse(true);

		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 0)
		equals(r.commonAncestorContainer.nodeType, 3)

		r.setStart(document.getElementById('strong').firstChild, 0);
		r.setEnd(document.getElementById('strong').firstChild, 6);

		r.collapse(false);

		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 6)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 6)
		equals(r.commonAncestorContainer.nodeType, 3)
	});

	test("test_selectNode", function() {
		var r = createRng();

		setup();
		expect(4);

		r.selectNode(document.getElementById('strong').firstChild);

		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 1)
	});

	test("test_selectNodeContents", function() {
		var r = createRng();

		setup();
		expect(8);

		r.selectNodeContents(document.getElementById('strong').firstChild);

		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 6)

		r.selectNodeContents(document.getElementById('first'));

		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 8)
	});

	test("test_insertNode", function() {
		var r = createRng();

		setup();
		expect(4);

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('first').firstChild, 2);
		r.insertNode(document.createTextNode('ABC'));

		equals(document.getElementById('first').childNodes[0].nodeValue, 'f')
		equals(document.getElementById('first').childNodes[1].nodeValue, 'ABC')
		equals(document.getElementById('first').childNodes[2].nodeValue, 'irst')

		r.selectNode(document.getElementById('strong'));
		r.insertNode(document.createElement('span'));

		equals(document.getElementById('strong').previousSibling.nodeName, 'SPAN')
	});

	test("test_cloneRange", function() {
		var r = createRng();

		setup();
		expect(6);

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('strong').firstChild, 2);

		var r2 = r.cloneRange();

		equals(r2.startContainer.nodeType, 3)
		equals(r2.startOffset, 1)
		equals(r2.endContainer.nodeType, 3)
		equals(r2.endOffset, 2)
		equals(r2.collapsed, false)
		equals(r2.commonAncestorContainer.nodeName, 'P')
	});

	test("test_cloneContents", function() {
		var r = createRng();

		setup();
		expect(77);

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('two').firstChild, 2);

		equals(getHTML(r.cloneContents()), '<p id="first">irst<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">ab</td></tr></tbody></table>')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 2)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeName, 'DIV')

		r.setStart(document.getElementById('two').firstChild, 1);
		r.setEnd(document.getElementById('last').firstChild, 2);

		equals(getHTML(r.cloneContents()), '<table id="table" width="300"><tbody><tr><td id="two">bc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">te</p>')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 2)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeName, 'DIV')

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('first').lastChild, 4);

		equals(getHTML(r.cloneContents()), 'irst<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> str')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 4)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeName, 'P')

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('first').firstChild, 4);

		equals(getHTML(r.cloneContents()), 'irs')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 4)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 3)

		r.setStart(document.getElementById('first'), 0);
		r.setEnd(document.getElementById('last'), 0);

		equals(getHTML(r.cloneContents()), '<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id=\"last\"></p>')
		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 0)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)

		r.setStart(document.getElementById('first'), 1);
		r.setEnd(document.getElementById('last'), 1);

		equals(getHTML(r.cloneContents()), '<p id="first"><!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc</p>')
		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 1)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)

		r.setStart(document.getElementById('sample'), 0);
		r.setEnd(document.getElementById('sample'), document.getElementById('sample').childNodes.length - 1);

		equals(getHTML(r.cloneContents()), '<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table>')
		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, document.getElementById('sample').childNodes.length - 1)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)

		r.setStart(document.getElementById('first'), 0);
		r.setEnd(document.getElementById('last').firstChild, 1);

		equals(getHTML(r.cloneContents()), '<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">t</p>')
		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 1)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('last'), 0);

		equals(getHTML(r.cloneContents()), '<p id="first">irst<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id=\"last\"></p>')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 0)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)

		r.setStart(document.getElementById('sample'), 0);
		r.setEnd(document.getElementById('traverse'), 2);

		equals(getHTML(r.cloneContents()), '<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em></p>')
		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 2)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)

		r.setStart(document.getElementById('sample'), 0);
		r.setEnd(document.getElementById('traverse'), 1);

		equals(getHTML(r.cloneContents()), '<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b></p>')
		equals(r.startContainer.nodeType, 1)
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 1)
		equals(r.collapsed, false)
		equals(r.commonAncestorContainer.nodeType, 1)
	});

	test("test_extractContents1", function() {
		var r = createRng();

		setup();
		expect(10);

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('first').firstChild, 4);

		equals(getHTML(r.extractContents()), 'irs')
		equals(r.startContainer.nodeType, 3)
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 3)
		equals(r.endOffset, 1)
		equals(r.collapsed, true)
		equals(r.startContainer == r.endContainer, true)
		equals(r.startOffset == r.endOffset, true)
		equals(r.commonAncestorContainer.nodeType, 3)
		equals(getHTML(document.getElementById('first')), '<p id="first">ft<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p>')
	});

	test("test_extractContents2", function() {
		var r = createRng();

		setup();
		expect(9);

		r.setStart(document.getElementById('two').firstChild, 1);
		r.setEnd(document.getElementById('last').firstChild, 2);

		equals(getHTML(r.extractContents()), '<table id="table" width="300"><tbody><tr><td id="two">bc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">te</p>')
		equals(r.startContainer.nodeType, 1)
		equals(getHTML(r.startContainer), '<div id="sample"><p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">a</td></tr></tbody></table><p id="last">xtabc<span>span</span></p></div>')
		equals(r.startOffset, 4)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 4)
		equals(getHTML(r.endContainer), '<div id="sample"><p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">a</td></tr></tbody></table><p id="last">xtabc<span>span</span></p></div>')
		equals(r.collapsed, true)
		equals(r.commonAncestorContainer.nodeName, 'DIV')
	});

	test("test_extractContents3", function() {
		var r = createRng();

		setup();
		expect(9);

		r.setStart(document.getElementById('sample'), 0);
		r.setEnd(document.getElementById('traverse'), 2);

		equals(getHTML(r.extractContents()), '<p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em></p>')
		equals(getHTML(r.startContainer), '<div id="sample"><p id="traverse">more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 0)
		equals(getHTML(r.endContainer), '<div id="sample"><p id="traverse">more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(getHTML(document.getElementById('sample')), '<div id="sample"><p id="traverse">more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.collapsed, true)
		equals(r.commonAncestorContainer.nodeName, 'DIV')
	});

	test("test_deleteContents1", function() {
		var r = createRng();

		setup();
		expect(8);

		r.setStart(document.getElementById('two').firstChild, 1);
		r.setEnd(document.getElementById('last').firstChild, 2);
		r.deleteContents();

		equals(getHTML(r.startContainer), '<div id="sample"><p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">a</td></tr></tbody></table><p id="last">xtabc<span>span</span></p></div>')
		equals(r.startOffset, 4)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 4)
		equals(getHTML(r.endContainer), '<div id="sample"><p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">a</td></tr></tbody></table><p id="last">xtabc<span>span</span></p></div>')
		equals(getHTML(document.getElementById('sample')), '<div id="sample"><p id="first">first<!--not--> strong <!-- --><strong id="strong">strong</strong> second <em id="em">em</em> strong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">a</td></tr></tbody></table><p id="last">xtabc<span>span</span></p></div>')
		equals(r.collapsed, true)
		equals(r.commonAncestorContainer.nodeName, 'DIV')
	});

	test("test_deleteContents2", function() {
		var r = createRng();

		setup();
		expect(8);

		r.setStart(document.getElementById('first').firstChild, 1);
		r.setEnd(document.getElementById('first').lastChild, 4);
		r.deleteContents();

		equals(getHTML(r.startContainer), '<p id="first">fong.</p>')
		equals(r.startOffset, 1)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 1)
		equals(getHTML(r.endContainer), '<p id="first">fong.</p>')
		equals(getHTML(document.getElementById('sample')), '<div id="sample"><p id="first">fong.</p><p id="second">bar</p><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.collapsed, true)
		equals(r.commonAncestorContainer.nodeName, 'P')
	});

	test("test_deleteContents3", function() {
		var r = createRng();

		setup();
		expect(8);

		r.setStart(document.getElementById('sample'), 0);
		r.setEnd(document.getElementById('sample'), 2);
		r.deleteContents();

		equals(getHTML(r.startContainer), '<div id="sample"><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 0)
		equals(getHTML(r.endContainer), '<div id="sample"><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(getHTML(document.getElementById('sample')), '<div id="sample"><p id="traverse"><b><em id="em">some text</em></b><em>em text</em>more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.collapsed, true)
		equals(r.commonAncestorContainer.nodeName, 'DIV')
	});

	test("test_deleteContents4", function() {
		var r = createRng();

		setup();
		expect(8);

		r.setStart(document.getElementById('sample'), 0);
		r.setEnd(document.getElementById('traverse'), 2);
		r.deleteContents();

		equals(getHTML(r.startContainer), '<div id="sample"><p id="traverse">more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.startOffset, 0)
		equals(r.endContainer.nodeType, 1)
		equals(r.endOffset, 0)
		equals(getHTML(r.endContainer), '<div id="sample"><p id="traverse">more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(getHTML(document.getElementById('sample')), '<div id="sample"><p id="traverse">more text</p><table id="table" width="300"><tbody><tr><td>1</td><td id="two">abc</td></tr><tr><td>3</td><td>4</td></tr></tbody></table><p id="last">textabc<span>span</span></p></div>')
		equals(r.collapsed, true)
		equals(r.commonAncestorContainer.nodeName, 'DIV')
	});

	run();
});
</script>
</body>
</html>
